package edu.webtek.cloudreq;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.Namespace;

public abstract class ReqBase {
	private final Namespace namespace = Namespace.getNamespace("http://www.cs.au.dk/dWebTek/2011");
	
	abstract public Document toDocument();
	protected Element createElement(String name, String value){
		Element out = new Element(name);
		if(value != null) {
			out.addContent(value);
		}
		out.setNamespace(namespace);
		return out;
	}
	
	protected Element createElement(String name, int itemID) {
		return createElement(name, Integer.toString(itemID) );
	}
	
	protected Element createElement(String name, Element ... children ){
		Element out = new Element(name);
		out.setNamespace(namespace);
		
		for(Element child: children){
			out.addContent(child);
		}
		
		return out;
	}
}
